﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace DB_NH.DB_Map.ywxt
{
    using NHibernate;
    using NHibernate.Mapping.ByCode;
    using NHibernate.Mapping.ByCode.Conformist;

    using DB_NH.DB_Model.ywxt;

    public class wf_node_Map : ClassMapping<wf_node>
    {
        public wf_node_Map()
        {
            //映射ID
            Id(x => x.n_id, map => map.Length(40));

            Property(x => x.is_valid);
            Property(x => x.create_date);

            Property(x => x.creator_name, map => map.Length(40));
            Property(x => x.n_begin_date);
            Property(x => x.n_code, map => map.Length(40));
            Property(x => x.n_contnent, map => map.Length(400));
            Property(x => x.n_do_flag);
            Property(x => x.n_end_date);
            Property(x => x.n_end_flag);
            Property(x => x.n_remark, map => map.Length(10000));
            Property(x => x.n_title, map => map.Length(400));

            //流程类型
            ManyToOne(x => x.n_type, map =>
            {
                map.Column(wf_node.Columns.n_type_id);
                map.NotNullable(false);
            });

            //创建人
            ManyToOne(x => x.creator_user, map =>
            {
                map.Column(wf_node.Columns.creator_id);
                map.NotNullable(false);
            });

            //关联专家抽取记录
            Bag(x => x.actions, map =>
            {
                map.Key(km => km.Column(DB_Model.ywxt.wf_action.Columns.node_id));
            }, act => act.OneToMany());

            Table(wf_node.TableName);

            //不进行创建
            SchemaAction(NHibernate.Mapping.ByCode.SchemaAction.None);
        }
    }
}
